#ifndef _SYS_OUT_STREAM_H_
#define _SYS_OUT_STREAM_H_

#include "FanObj.h"
#include "SysTypes.h"

#define OUT_STREAM_VTABLE(self)   ((OutStreamVTable*)((FanObj*)self)->vtable)


extern Type*    OutStream_classType;
extern VTable*  OutStream_classVTable;


/* [sys::OutStream] Attributes */
struct OutStream
{
  FanObj        super;
  OutStream*    out;
  Bool          bigEndian;
  Charset*      charset;
};


/* [sys::OutStream] Virtual-table */
typedef struct OutStreamVTable
{
  FanObjVTable  super;
  Bool          (*close)(OutStream* self);
  OutStream*    (*flush)(OutStream* self);
  OutStream*    (*sync)(OutStream* self);
  OutStream*    (*write)(OutStream* self, Int byte);
  OutStream*    (*writeBuf_1)(OutStream* self, Buf* buf);
  OutStream*    (*writeBuf)(OutStream* self, Buf* buf, Int n);

  /* Internal virtual methods */
  OutStream*    (*writeChar)(OutStream* self, Int ch);
  OutStream*    (*writeChars)(OutStream* self, Str* str, Int off, Int len);
} OutStreamVTable;


/* [sys::OutStream] Methods and fields */
void            OutStream_make(OutStream* self, OutStream* out);
Endian*         OutStream_endian(OutStream* self);
void            OutStream_setEndian(OutStream* self, Endian* val);
Charset*        OutStream_charset(OutStream* self);
void            OutStream_setCharset(OutStream* self, Charset* val);
Int             OutStream_xmlEscNewlines(void);
Int             OutStream_xmlEscQuotes(void);
Int             OutStream_xmlEscUnicode(void);
OutStream*      OutStream_write(OutStream* self, Int byte);
OutStream*      OutStream_writeBuf_1(OutStream* self, Buf* buf);
OutStream*      OutStream_writeBuf(OutStream* self, Buf* buf, Int n);
OutStream*      OutStream_flush(OutStream* self);
OutStream*      OutStream_sync(OutStream* self);
Bool            OutStream_close(OutStream* self);
OutStream*      OutStream_writeI2(OutStream* self, Int n);
OutStream*      OutStream_writeI4(OutStream* self, Int n);
OutStream*      OutStream_writeI8(OutStream* self, Int n);
OutStream*      OutStream_writeF4(OutStream* self, Float r);
OutStream*      OutStream_writeF8(OutStream* self, Float r);
OutStream*      OutStream_writeDecimal(OutStream* self, Decimal* d);
OutStream*      OutStream_writeBool(OutStream* self, Bool b);
OutStream*      OutStream_writeUtf(OutStream* self, Str* s);
OutStream*      OutStream_writeChar(OutStream* self, Int ch);
OutStream*      OutStream_writeChars_1(OutStream* self, Str* str);
OutStream*      OutStream_writeChars_2(OutStream* self, Str* str, Int off);
OutStream*      OutStream_writeChars(OutStream* self, Str* str, Int off, Int len);
OutStream*      OutStream_print(OutStream* self, NullableObj s);
OutStream*      OutStream_printLine_0(OutStream* self);
OutStream*      OutStream_printLine(OutStream* self, NullableObj obj);
OutStream*      OutStream_writeObj_1(OutStream* self, NullableObj obj);
OutStream*      OutStream_writeObj(OutStream* self, NullableObj obj, Map* options);
OutStream*      OutStream_writeProps_1(OutStream* self, Map* props);
OutStream*      OutStream_writeProps(OutStream* self, Map* props, Bool close);
OutStream*      OutStream_writeXml_1(OutStream* self, Str* str);
OutStream*      OutStream_writeXml(OutStream* self, Str* str, Int mode);


/* [sys::OutStream] Type-system functions */
Type*           OutStream_initType(void);
VTable*         OutStream_initVTable(void);
void            OutStream_initStatic(void);


#endif
